<?php

namespace App\Http\Requests\Admin;

use App\Http\Requests\ApiRequest;
use Illuminate\Http\UploadedFile;

/**
 * @property int super_id
 * @property string name
 * @property string description
 * @property int priority
 * @property UploadedFile thumb
 */
class ProductCategoriesStoreRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'super_id'    => 'required|numeric',
            'name'        => 'required|string',
            'description' => 'sometimes|string',
            'priority'    => 'sometimes|numeric',
            'thumb'       => 'sometimes|file',
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'super_id.*'    => ':attribute必须是数字',
            'name.*'        => ':attribute必须是字符串',
            'description.*' => ':attribute必须是字符串',
            'priority.*'    => ':attribute必须是数字',
            'thumb.*'       => ':attribute必须是上传的图片',
        ];
    }

    /**
     * @return array
     */
    public function attributes()
    {
        return [
            'super_id'    => '上级的id',
            'name'        => '种类名称',
            'description' => '种类描述',
            'priority'    => '优先级',
            'thumb'       => '产品类别图',
        ];
    }
}
